package com.liuyun.sunadmin;

import com.liuyun.sunadmin.exceptions.ParamsException;
import com.liuyun.sunadmin.model.RespBean;
//import org.springframework.sunadmin.access.AccessDeniedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(ParamsException.class)
    @ResponseBody
    public RespBean paramsExceptionHander(ParamsException e)
    {
        return RespBean.error(e.getMsg());
    }

//    @ExceptionHandler(AccessDeniedException.class)
//    public String accessDeniedException(AccessDeniedException e){
//        return "403";
//    }

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public RespBean exceptionHander(Exception e)
    {
        return RespBean.error(e.getMessage(),"{}");
    }
}
